@namespace Oqtane.Themes.Controls
@inherits MenuItemsBase

@if (ParentPage != null)
{
    foreach (var childPage in GetChildPages())
    {
        var _attributes = new Dictionary<string, object>();
        _attributes.Add("href", GetUrl(childPage));
        var _target = GetTarget(childPage);
        if (!string.IsNullOrEmpty(_target))
        {
            _attributes.Add("target", _target);
        }
        if (childPage.PageId == PageState.Page.PageId)
        {
            <li class="nav-item px-3" style="margin-left: @(childPage.Level * 15)px;">
                <a class="nav-link active" @attributes="_attributes">
                    <span class="w-100" data-bs-toggle="collapse" data-bs-target=".navbar-collapse.show">
                        <span class="@childPage.Icon" aria-hidden="true" />
                        @childPage.Name <span class="visually-hidden-focusable">(current)</span>
                    </span>
                </a>
            </li>
        }
        else
        {
            <li class="nav-item px-3" style="margin-left: @(childPage.Level * 15)px;">
                <a class="nav-link" @attributes="_attributes">
                    <span class="w-100" data-bs-toggle="collapse" data-bs-target=".navbar-collapse.show">
                        <span class="@childPage.Icon" aria-hidden="true" />
                        @childPage.Name
                    </span>
                </a>
            </li>
        }
        if (Pages.Any(e => e.ParentId == childPage.PageId))
        {
            <MenuItemsVertical ParentPage="childPage" Pages="Pages" />
        }
    }
}
else
{
    <ul class="nav flex-column">
        @foreach (var childPage in GetChildPages())
        {
            var _attributes = new Dictionary<string, object>();
            _attributes.Add("href", GetUrl(childPage));
            var _target = GetTarget(childPage);
            if (!string.IsNullOrEmpty(_target))
            {
                _attributes.Add("target", _target);
            }
            if (childPage.PageId == PageState.Page.PageId)
            {
                <li class="nav-item px-3" style="margin-left: @(childPage.Level * 15)px;">
                    <a class="nav-link active" @attributes="_attributes">
                        <span class="w-100" data-bs-toggle="collapse" data-bs-target=".navbar-collapse.show">
                            <span class="@childPage.Icon" aria-hidden="true" />
                            @childPage.Name <span class="visually-hidden-focusable">(current)</span>
                        </span>
                    </a>
                </li>
            }
            else
            {
                <li class="nav-item px-3" style="margin-left: @(childPage.Level * 15)px;">
                    <a class="nav-link" @attributes="_attributes">
                        <span class="w-100" data-bs-toggle="collapse" data-bs-target=".navbar-collapse.show">
                            <span class="@childPage.Icon" aria-hidden="true" />
                            @childPage.Name
                        </span>
                    </a>
                </li>
            }
            if (Pages.Any(e => e.ParentId == childPage.PageId))
            {
                <MenuItemsVertical ParentPage="childPage" Pages="Pages" />
            }
        }
    </ul>
}